package com.yanqu.road.server.cmd.cookboy.process2;

import com.yanqu.road.entity.player.UserBaseInfo;
import com.yanqu.road.logic.pb.PlayerBasePb;
import com.yanqu.road.pb.cookboy.CookBoyProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.cookboy.CrossCookBoyMgr;
import com.yanqu.road.server.manager.user.CrossUserMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = Protocol.C_CROSS_COOK_BOY2_HORSE_RACE_LAMP, desc = "跑马灯")
public class CrossAddHorseCmd extends CrossCommand {

    private int activityId;
    private long userId;
    private int dishId;
    private long time;
    private UserBaseInfo userBaseInfo;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        CookBoyProto.CrossCookBoy2HorseNoticeMsg reqMsg = CookBoyProto.CrossCookBoy2HorseNoticeMsg.parseFrom(packet.getBytes());
        userId = reqMsg.getUserId();
        activityId = reqMsg.getActivityId();
        dishId = reqMsg.getDishId();
        time = reqMsg.getTime();
        userBaseInfo = PlayerBasePb.parseToUserBaseInfo(reqMsg.getPlayerBaseData());
        CrossUserMgr.updateUserBaseInfo(userId,userBaseInfo);
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        CrossCookBoyMgr.addCookBoy2Horse(activityId,serverId,userId,dishId,time);
    }

    @Override
    public void sendData() {

    }

}
